package com.easy.modules.sysmgr.entity;

import java.sql.Clob;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.easy.modules.common.RecordEntity;

@Entity
@Table(name = "EASY_SYSMGR_DEPT")
@DynamicUpdate(true)
@DynamicInsert(true)
public class DeptEntity extends RecordEntity {

	private String name ;						//部门名称
	
	private String tel ;						//联系电话
	
	private String fax ;						//传真号码
	
	private String position ;					//部门位置
	
	private Clob duty ;							//部门职责
	
	private Clob year_target ;					//年度目标
	
	private Clob work_plan ;					//工作计划
	
	private Clob remark ;						//备注
	
	
	private Set<DeptEntity> depts = new HashSet<DeptEntity>(0) ;

	private DeptEntity dept;
	
	private CompanyEntity company ;

	private Set<UserEntity> users = new HashSet<UserEntity>();
	
	
	@ManyToOne
	@JoinColumn(name = "COMPANY_ID")
	public CompanyEntity getCompany() {
		return company;
	}

	public void setCompany(CompanyEntity company) {
		this.company = company;
	}

	@OneToMany
	@JoinColumn(name = "DEPT_ID")
	public Set<UserEntity> getUsers() {
		return users;
	}

	public void setUsers(Set<UserEntity> users) {
		this.users = users;
	}

	@OneToMany(mappedBy = "dept", fetch = FetchType.LAZY)
	@OrderBy("created desc")
	public Set<DeptEntity> getDepts() {
		return depts;
	}

	public void setDepts(Set<DeptEntity> depts) {
		this.depts = depts;
	}

	@ManyToOne
	@JoinColumn(name = "DEPT_PID")
	public DeptEntity getDept() {
		return dept;
	}

	public void setDept(DeptEntity dept) {
		this.dept = dept;
	}

	public String getTel() {
		return tel;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public Clob getDuty() {
		return duty;
	}

	public void setDuty(Clob duty) {
		this.duty = duty;
	}

	public Clob getYear_target() {
		return year_target;
	}

	public void setYear_target(Clob year_target) {
		this.year_target = year_target;
	}

	public Clob getWork_plan() {
		return work_plan;
	}

	public void setWork_plan(Clob work_plan) {
		this.work_plan = work_plan;
	}

	public Clob getRemark() {
		return remark;
	}

	public void setRemark(Clob remark) {
		this.remark = remark;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
